<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<center>
    <table>
        <tr>
            <td>商品名称</td>
            <td>商品单价</td>
            <td>商品数量</td>
            <td>现价</td>
            <td>操作</td>
        </tr>
        <?php
        foreach($res as $k=>$v){
        ?>
        <tr>
            <td><?= $v['s_name']?></td>
            <td><?=$v['s_price']?></td>
            <td><?=$v['s_stock']?></td>
            <td>￥1.00</td>
            <td><input type="button" value="抢购" class="but" daty="<?=$v['s_id']?>"/></td>
        </tr>
        <?php  } ?>
    </table>
</center>
</body>
</html>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
    $(".but").click(function(){
        var id=$(this).attr("daty");
        $.ajax({
            url:"qiang.php",
            data:{id:id},
            dataType:"json",
            type:"post",
            success:function(res){
                alert(res.msg);
                location.reload();
            }
        });
    })
</script>